 1.Apache Kylin 实战之Kylin安装
   
   1).依赖环境
   软件      版本
   Hive      2.3.7
   Hadoop    2.9.2
   HBase     1.3.1
   Zookeeper 3.4.14
   Kafka     1.0.2
   Spark     2.4.5
   2).集群规划
   注意：
       要求hbase的hbase.zookeeper.quorum值必须只能是host1、host2、...。不允
许出现host:2181。 hbase-site.xml文件：
<configuration>
	<!-- 指定hbase在HDFS上存储的路径 -->
	<property>
		<name>hbase.rootdir</name>
		<value>hdfs://linux121:9000/hbase</value>
	</property>
	<!-- 指定hbase是分布式的 -->
	<property>
		<name>hbase.cluster.distributed</name>
		<value>true</value>
	</property>
	<!-- 指定zk的地址，多个用“,”分割 -->
	<property>
		<name>hbase.zookeeper.quorum</name>
		<value>linux121,linux122,linux123</value>
	</property>
</configuration>
   3).Kylin安装配置
   (1).解压缩软件(apache-kylin-3.1.1-bin-hbase1x.tar.gz)，并移动到
/opt/lagou/servers 目录下
   cd /opt/lagou/software
   tar zxvf apache-kylin-3.1.1-bin-hbase1x.tar.gz
   mv apache-kylin-3.1.1-bin-hbase1x/ ../servers/kylin-3.1.1
   cd ../servers/kylin-3.1.1
   (2).添加环境变量，并使之生效
   vi /etc/profile
# 增加以下内容
export KYLIN_HOME=/opt/lagou/servers/kylin-3.1.1
export PATH=$PATH:$KYLIN_HOME/bin
   source /etc/profile
   (3).增加kylin依赖组件的配置
   cd $KYLIN_HOME/conf
ln -s $HADOOP_HOME/etc/hadoop/hdfs-site.xml hdfs-site.xml
ln -s $HADOOP_HOME/etc/hadoop/core-site.xml core-site.xml
ln -s $HBASE_HOME/conf/hbase-site.xml hbase-site.xml
ln -s $HIVE_HOME/conf/hive-site.xml hive-site.xml
ln -s $SPARK_HOME/conf/spark-defaults.conf spark-defaults.conf
   (4).修改 kylin.sh
   cd $KYLIN_HOME/bin
vim kylin.sh
# 在 kylin.sh 文件头部添加
export HADOOP_HOME=/opt/lagou/servers/hadoop-2.9.2
export HIVE_HOME=/opt/lagou/servers/hive-2.3.7
export HBASE_HOME=/opt/lagou/servers/hbase-1.3.1
export SPARK_HOME=/opt/lagou/servers/spark-2.4.5
   (5).检查依赖
   $KYLIN_HOME/bin/check-env.sh
   错误处理：
   /opt/lagou/servers/kylin-3.1.1/bin/check-port-availability.sh:
line 30: netstat: command not found
   解决：yum install net-tools
   4).启动集群
   1 、启动 zookeeper（linux121）
   2 、启动 HDFS（linux121）
   3 、启动 YARN （linux123）
   4 、启动 HBase（linux121）
   5 、启动 metastore（linux123）
   nohup hive --service metastore & 
   6 、启动Yarn history server（linux121）
   mr-jobhistory-daemon.sh start historyserver 
   7 、启动 kylin
   kylin.sh start 
   8、登录 Kylin Web界面
   URL        http://linux122:7070/kylin
   默认用户名 ADMIN
   默认密码   KYLIN
       备注：用户名和密码都必须是大写
   5).Troubleshooting
   备注：如在Kylin构建Cube的过程中没有问题，以下部分可以略过
   如果在使用Kylin构建Cube的过程中，遇到以下报错：
   找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster
   解决方案：
   1 、在命令行中输入命令
   [root@linux122 bin]# hadoop classpath
/opt/lagou/servers/hadoop-2.9.2/etc/hadoop:
/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/etc/hadoop
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/etc/hadoop
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
*/
   2 、把上述输出的值，添加到yarn-site.xml文件对应的属性
<property>
    <name>yarn.application.classpath</name>
    <value>/opt/lagou/servers/hadoop-2.9.2/etc/hadoop:
/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/etc/hadoop
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/etc/hadoop
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/common/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/hdfs/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/yarn/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
:/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
:/opt/lagou/servers/hadoop-2.9.2/contrib/capacity-scheduler/*.jar
</value>
</property>
*/
   3 、重启yarn，重新执行Cube构建任务
   如果在使用Kylin构建Cube的过程中，遇到以下类似报错：
Exception from container-launch.
Container id: container_1621524388361_0001_02_000001
Exit code: 1
Container exited with a non-zero exit code 1. Error file:
prelaunch.err.
java.io.FileNotFoundException:
/home/hadoop/hadoop-.9.2/logs/userlogs/application_16215243883
61_0001/container_1621524388361_0001_02_000001 (是一个目录)   
   解决方案：
   在mapred-site.xml文件中添加mapreduce所需要用到的classpath
<property>
	<name>mapreduce.application.classpath</name>
	<value>/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/*, 
/opt/lagou/servers/hadoop-2.9.2/share/hadoop/mapreduce/lib/*
	</value>
</property>
*/
   4 、重新执行Cube构建任务


   
  

      